﻿<phone:PhoneApplicationPage
    x:Class="Shortcuts.Views.Home"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True"
    toolkit:TiltEffect.IsTiltEnabled="True">

    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="TileTitleStyle" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Bottom"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="Margin" Value="6 3"/>
        </Style>
        <Style x:Key="TileButtonStyle" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <StackPanel VerticalAlignment="Top"
                                    Margin="10" 
                                    Width="173" 
                                    Height="173"
                                    Background="{StaticResource PhoneAccentBrush}">
                            <ContentPresenter />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <ScrollViewer Grid.Row="1">
            <StackPanel Margin="12 0">

                <StackPanel Orientation="Horizontal">
                    <Button Command="{Binding TileCommand}" 
                        CommandParameter="WiFi"
                        Style="{StaticResource TileButtonStyle}">
                        <Grid>
                            <Image Source="/Images/wifi.png"/>
                            <TextBlock Text="{Binding WiFi}" Style="{StaticResource TileTitleStyle}"/>
                        </Grid>
                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu>
                                <toolkit:MenuItem Header="{Binding Open}"
                                              Command="{Binding TileCommand}"
                                              CommandParameter="WiFi"/>
                                <toolkit:MenuItem Header="{Binding Pin}"
                                              Command="{Binding WiFiPinCommand}"/>
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>
                    </Button>
                    <Button Command="{Binding TileCommand}"
                        CommandParameter="Cellular"
                        Style="{StaticResource TileButtonStyle}">
                        <Grid>
                            <Image Source="/Images/cellular.png"/>
                            <TextBlock Text="{Binding Cellular}" Style="{StaticResource TileTitleStyle}"/>
                        </Grid>
                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu>
                                <toolkit:MenuItem Header="{Binding Open}"
                                              Command="{Binding TileCommand}"
                                              CommandParameter="Cellular"/>
                                <toolkit:MenuItem Header="{Binding Pin}"
                                              Command="{Binding CellularPinCommand}" />
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>
                    </Button>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button Command="{Binding TileCommand}" 
                        CommandParameter="Airplane"
                        Style="{StaticResource TileButtonStyle}">
                        <Grid>
                            <Image Source="/Images/airplane.png"/>
                            <TextBlock Text="{Binding Airplane}" Style="{StaticResource TileTitleStyle}"/>
                        </Grid>
                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu>
                                <toolkit:MenuItem Header="{Binding Open}"
                                              Command="{Binding TileCommand}"
                                              CommandParameter="Airplane"/>
                                <toolkit:MenuItem Header="{Binding Pin}" 
                                              Command="{Binding AirplanePinCommand}"/>
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>
                    </Button>
                    <Button Command="{Binding TileCommand}" 
                        CommandParameter="Bluetooth"
                        Style="{StaticResource TileButtonStyle}">
                        <Grid>
                            <Image Source="/Images/bluetooth.png"/>
                            <TextBlock Text="{Binding Bluetooth}" Style="{StaticResource TileTitleStyle}"/>
                        </Grid>
                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu>
                                <toolkit:MenuItem Header="{Binding Open}"
                                              Command="{Binding TileCommand}"
                                              CommandParameter="Bluetooth"/>
                                <toolkit:MenuItem Header="{Binding Pin}"
                                              Command="{Binding BluetoothPinCommand}"/>
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>
                    </Button>
                </StackPanel>
            </StackPanel>
        </ScrollViewer>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Mode="Default" IsVisible="True">
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>